<script lang="ts">

  import router from '@/router'
  import axios from 'axios'
  import type { StockInfoModel } from '@/model/StockInfoModel'

  export default {
    data() {
      const emptyStockInfoList: Array<StockInfoModel> = []
      return { stockInfoList: emptyStockInfoList }
    },
    mounted() {
      axios.get('src/assets/config.json')
        .then(response => axios.get(`${response.data.url}reduce_stock_holder`, { method: 'GET' }))
        .then(response => {
          const stockInfoModelList: Array<StockInfoModel> = response.data
          stockInfoModelList.forEach(stockInfo => this.stockInfoList.push(stockInfo))
        })
        .catch(err => console.log(err))
    },
    methods: {
      jumpStockNorm: function(ts_code: string) {
        router.push({ name: 'stockNorm', query: { ts_code } })
      }
    }
  }

</script>

<template>
    <li v-for="stockInfo in stockInfoList" @click="jumpStockNorm(stockInfo.ts_code)">
        {{ stockInfo.ts_code }} - {{ stockInfo.name }} - {{ stockInfo.industry }} - {{ stockInfo.market }} -
        {{ stockInfo.list_date }} - {{ stockInfo.pe }} - {{ stockInfo.pe_ttm }} - {{ stockInfo.total_mv }}
    </li>
</template>
